home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
program
/
snpd9611.zip
/
FASKBHIT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-11-24
|
1KB
|
59 lines
.I 0 3
/* +++Date last modified: 23-Nov-1996 */
/*
.D 1 1
.I 2 3
**
** Revisions:
** 30-Mar-96 Ed Blackman OS/2 mods
.I 6 1
#include "snipkbio.h"
.I 10 30
#if defined(__OS2__)
/* 30-Mar-96 - EBB: it really isn't good to poll the keyboard in OS/2.
** A better design would be to call KbdCharIn(..., IO_WAIT, ...) in a
** separate thread, and sending a message via some form of IPC to the main
** thread when a key is available. This code is intended to be more of an
** example of how to use the API, rather than something you would copy into
** production code.
*/
int fast_kbhit_os2(void)
{
extern KBDKEYINFO ki; /* defined in ISSHIFT.C */
KbdPeek(&ki, 0); /* peek in the keyboard buffer */
DosSleep(1); /* give up the rest of the time slice */
return (ki.fbStatus & (1 << 6)); /* only return true if key is 'final' */
}
void fast_kbflush_os2(void)
{
KbdFlushBuffer(0);
}
#else /* assume DOS */
#define biosseg 0x40
#define HEAD (*((unsigned short FAR *)MK_FP(biosseg, 0x1a)))
#define TAIL (*((unsigned short FAR *)MK_FP(biosseg, 0x1c)))
.D 11 4
.I 21 6
int retval;
disable();
retval = HEAD - TAIL;
enable();
return retval;
.D 22 1
.I 30 5
disable();
HEAD = TAIL;
enable();
}
#endif /* !__OS2__ */
.D 31 2